package com.joysuch.wwyt.bp.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_bp_work_safety_cert_type")
@SQLDelete(sql = "update wwyt_bp_work_safety_cert_type set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_bp_work_safety_cert_type set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
@Proxy(lazy = false)
public class BpWorkSafetyCertType implements Serializable {
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    private Long id;

    //类型名称
    @Column(name = "name")
    private String name;

    //作业级别:0特级;1:一级;2:二级;3:三级
    @Column(name = "work_level")
    private Integer workLevel;

    //同步状态:0加载;1未加载
    @Column(name = "sync_state")
    private Integer syncState;

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "create_by")
    private Long createBy;

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "create_time")
    private Date createTime;

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "update_by")
    private Long updateBy;

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "update_time")
    private Date updateTime;

    @Column(name = "deleteFlag")
    private String deleteFlag;

    @Column(name = "orgCode")
    private String orgCode;

    @Column(name = "tenentId")
    private Long tenentId;

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BpWorkSafetyFileAnalyze == false)
            return false;
        if (this == obj)
            return true;
        BpWorkSafetyFileAnalyze other = (BpWorkSafetyFileAnalyze) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
